const BASE_URL='https://api-hmugo-web.itheima.net/api'
export const request =(options)=>{
	return new Promise((reslove,reject)=>{
		uni.request({
			url:BASE_URL+options.url,
			method:options.method||'GET',
			data:options.data||{},
			success: (res) => {
				if(res.data.meta.status!==200){
					uni.showToast({
						icon:'error',
						title:'操作错误',
						duration:1500
					})
				}
				reslove(res)
			},
			fail: (error) => {
				uni.showToast({
					icon:"error",
					title:'系统错误',
					duration:1500
				})
				reject(error)
			}
		})
	})
}
uni.addInterceptor('request',{
	invoke() {
		uni.showLoading({
			title:"加载中..."
		});
	},
	success() {
		uni.hideLoading();
	}
})